package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.rare;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.Ref;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;

public class VampireSkill extends BaseSkill {

    public VampireSkill(int level) {
        super(level);
    }

    public VampireSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public VampireSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("吸血技能，攻击时候恢复对应的(max(造成伤害,造成伤害*技能等级*0.5))生命。");
    }

    public SkillRarity getSkillRarity() {
        return SkillRarity.Rare;
    }

    @Override
    public boolean onAttack(MobEntity attacker, LivingEntity target, DamageSource source, Ref<Float> amount, boolean ismob, boolean remote) {
        if (amount.getValue() * 0.1F * getSkillLevel() > amount.getValue()) {
            attacker.heal(amount.getValue());
        } else {
            attacker.heal(amount.getValue() * 0.25F * getSkillLevel());
        }
        return true;
    }
}
